package com.example.a2205douyin.db;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.a2205douyin.entity.VideoEntity;

import java.util.List;

/**
 * 对数据库中的表video进行增删改查等操作
 */

@Dao
public interface VideoDao {
    //新增数据  onConflict = OnConflictStrategy.REPLACE 再次保存时，可更新原来的数据，两次点击不会报错
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertVideo(VideoEntity.DataBean video);
    //更新指定数据
    @Update
    void updateVideo(VideoEntity.DataBean video);
    //删除指定数据
    @Delete
    void deleteVideo(VideoEntity.DataBean video);
    //查询所有
    @Query("select * from video")
    List<VideoEntity.DataBean> queryAll();
    //查询符合条件的值---根据作者名称查询
    @Query("select * from video where authname = :name")
    List<VideoEntity.DataBean> queryByName(String name);
}
